/* ************************************************************************** */^M
/* Example of a syndication feed reader using the Project Rome API with       */^M
/* BSF4ooRexx                                                                 */^M
/* current version of Rome: rome1.0.jar            https://rome.dev.java.net/ */^M
/* You need to implement this API plus the JDOM API                           */^M
/* jdom.jar  ,   you can find this at               https://jdom.org/        ; */^M
/*                                                                            */^M
/* This class retrieves a syndfeed from the web and prints it to the system   */^M
/* using the syndfeed Outout and the wirefeed Output                          */                      ^M
/* created by Martin Stoppacher     date:   26.12.2009    (c) 2009            */^M
/* license:ÊÊÊÊLGPL 3.0ÊÊÊÊÊÊÊused versions: Java 1.6, ooRexx 4.0, Bsf4ooRexx */^M
/*             (Lesser Gnu Public License version 3.0),                       */^M
/*             cf. <http://www.gnu.org/licenses/lgpl.html>                    */^M
/* ************************************************************************** */^M
^M
/* grafical part                                                     */^M
^M
frame=.bsf~new("java.awt.Frame", "Please enter the url")^M
frame~bsf.addEventListener( 'window', 'windowClosing', 'call BSF "exit"')^M
frame~setLayout( .bsf~new("java.awt.FlowLayout") )^M
^M
tf=.bsf~new("java.awt.TextField", "http://rss.orf.at/fm4.xml", 50)^M
^M
type=.bsf~new("java.awt.TextField", "rss_2.0", 50)^M
^M
but=.bsf~new('java.awt.Button', 'retrieve feed')^M
but~bsf.addEventListener('action', '', ' call text tf,type ')^M
^M
lable1=.bsf~new('java.awt.Label', "Feed URL:") ^M
lable2=.bsf~new('java.awt.Label', "Feed Type:")^M
^M
frame~add(lable1)^M
frame~add(tf)^M
frame~add(lable2)^M
frame~add(type)^M
frame~add(but)^M
^M
frame~~pack~~show~~toFront^M
^M
do forever^M
INTERPRET .bsf~bsf.pollEventText^M
if result="SHUTDOWN, REXX !" then leave^M
end^M
exit^M
^M
text: --procedure^M
use arg tf,type    ^M
 ^M
say hello this reads a syndfeed^M
--say please type in the url^M
-- pull url                                             /* optional url input */^M
--url="http://rss.orf.at/fm4.xml"^M
url = tf~getText ^M
^M
typet= type~getText                              /* optional rss tape parts */^M
--pull typet ^M
--typet="rss_2.0"^M
^M
fileName2 = "test2_printed_from_syndfeed" typet ^M
fileName3 = "test3_printed_from_wirefeed"^M
^M
feedUrl=.bsf~new("java.net.URL", url)              /* ocreating a URL object  */^M
say connecting__ || feedUrl~getAuthority()^M
^M
call Syssleep 1^M
^M
input=.bsf~new("com.sun.syndication.io.SyndFeedInput")^M
/*  creates a SyndFeedInput , an independent object model  instance           */^M
xmlr=.bsf~new("com.sun.syndication.io.XmlReader", feedUrl)^M
/*     Figures out the charset encoding of the XML document within the stream */^M
^M
input~setXmlHealerOn(0)                                  /* set healer on off */^M
say input~getXmlHealerOn()                           /* checks for xml healer */^M
^M
feed=input~build(xmlr)^M
fileName1 = "test1_original_syndfeed" feed~getFeedType()   ^M
^M
/*                 writer part: saves the feed file as XML code to the system */^M
/*                 this writes the original feed to a file                    */^M
writer=.bsf~new("java.io.FileWriter",fileName1)^M
output=.bsf~new("com.sun.syndication.io.SyndFeedOutput") ^M
output~output(feed,writer)^M
writer~close()^M
^M
say output~outputString(feed,0)       /* usage of pretty print(0 yes or 1 no) */^M
^M
say feed~getFeedType()^M
say "-----"^M
^M
feed~setFeedType(typet)^M
^M
writer2=.bsf~new("java.io.FileWriter",fileName2)^M
output2=.bsf~new("com.sun.syndication.io.SyndFeedOutput") ^M
output2~output(feed,writer2)    ^M
/*  output method of the SyndFeedOutput writes feed with the java file writer */^M
writer2~close()^M
^M
say output2~outputString(feed,0) -- usage of pritty print(0 yes or 1 no)^M
^M
say feed~getFeedType()^M
say "-----"^M
^M
wfeed = feed~createWireFeed("rss_1.0")^M
^M
writer3=.bsf~new("java.io.FileWriter",fileName3)^M
output3=.bsf~new("com.sun.syndication.io.WireFeedOutput")^M
output3~output(wfeed,writer3)     -- also possible with pretty print^M
writer3~close()^M
^M
say output3~outputString(wfeed,0)  -- usage of pretty print(0 yes or 1 no)^M
^M
say wfeed~getFeedType()^M
say "-----"^M
say done^M
^M
/* Optional grafical part                                                     */^M
^M
do forever^M
INTERPRET .bsf~bsf.pollEventText^M
end^M
^M
::requires BSF.cls